import { Logger } from "../engine/utils/Logger"

export class DbConfig {

    public static Db_Type = {
        Dev: 1,
        Test: 2,
        Online:3,
        yueyouhui:4,
        xj:6,
        chaoju_new:7,
        Jk:8,
        chaoyou:9,
    }

    public static now_db_type: number = DbConfig.Db_Type.Online

    public static Db_Name = {
        db_account: "db_account", //数据库,
        db_yuxiaxie:"db_yuxiaxie",
        db_laoyou: "db_laoyou", //数据库,
        db_yxx:"laoyou",
    }

    public host: string = ""
    public port: number = 3306
    public user: string = ""
    public pass: string = ""

    constructor(host: string, port: number, user: string, pass: string) {
        this.host = host;
        this.port = port;
        this.user = user;
        this.pass = pass;
    }

    private static dbMap: Map<number, DbConfig> = new Map<number, DbConfig>()
        .set(DbConfig.Db_Type.Dev, new DbConfig("121.37.251.120", 3306, "root", "f301517757c8cf6c"))
        .set(DbConfig.Db_Type.Test, new DbConfig("127.0.0.1", 3306, "root", "f301517757c8cf6c"))
        .set(DbConfig.Db_Type.Online, new DbConfig("127.0.0.1", 3306, "root", "f301517757c8cf6c"))
        .set(DbConfig.Db_Type.chaoju_new, new DbConfig("127.0.0.1", 3306, "root", "f301517757c8cf6c"))
        .set(DbConfig.Db_Type.yueyouhui, new DbConfig("127.0.0.1", 3306, "root", "f301517757c8cf6c"))
        .set(DbConfig.Db_Type.xj, new DbConfig("127.0.0.1", 3306, "root", "f301517757c8cf6c"))
        .set(DbConfig.Db_Type.Jk, new DbConfig("127.0.0.1", 3306, "root", "f301517757c8cf6c"))
        .set(DbConfig.Db_Type.chaoyou, new DbConfig("127.0.0.1", 3306, "root", "f301517757c8cf6c"))
   

    public static init(dbType: number = DbConfig.Db_Type.Dev) {
        this.now_db_type = dbType
    }

    public static getDbConfig(dbType: number): DbConfig {
        let db: DbConfig = this.dbMap.get(dbType);
        if (db) {
            return db;
        } else {
            Logger.error("不存在数据库配置:" + dbType)
        }
    }
}

